<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>短信平台</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" th:href="@{/vendor/bootstrap/css/bootstrap.min.css}">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" th:href="@{/vendor/font-awesome/css/font-awesome.css}">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" th:href="@{/css/fontastic.css}">
    <!-- Google fonts - Roboto -->
    <!--<link rel="stylesheet" th:href="@{https://fonts.googleapis.com/css?family=Roboto:300,400,500,700}">-->
    <!-- jQuery Circle-->
    <link rel="stylesheet" th:href="@{/css/grasp_mobile_progress_circle-1.0.0.min.css}">
    <!-- Custom Scrollbar-->
    <link rel="stylesheet" th:href="@{/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css}">
    <!-- theme stylesheet-->
    <link rel="stylesheet" th:href="@{/css/style.blue.css}" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" th:href="@{/css/custom.css}">
    <!--toastr-->
    <link rel="stylesheet" th:href="@{/css/toastr.css}">
    <!-- Favicon-->
    <link rel="shortcut icon" th:href="@{/img/favicon.ico}">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
    <meta name="_csrf" th:content="${_csrf.token}"/>
    <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
    <style type="text/css">
        .table {
            table-layout: fixed;
        }

        .table th {
            text-align: center;
        }

        .table tr td {
            text-overflow: ellipsis; /* for IE */
            -moz-text-overflow: ellipsis; /* for Firefox,mozilla */
            overflow: hidden;
            white-space: nowrap;
            text-align: left;
        }
    </style>
</head>

<body>
<!-- Side Navbar -->
<div th:replace="~{/pages/common/side_navbar.html}"></div>
<div class="page">
    <!-- navbar-->
    <div th:replace="~{/pages/common/header_navbar.html}"></div>

    <!--页码代码-->
    <!-- Breadcrumb-->
    <div class="breadcrumb-holder">
        <div class="container-fluid">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="#">已发送</a></li>
            </ul>
        </div>
    </div>
    <section>
        <div class="container-fluid">
            <!-- Page Header-->
            <div class="row">
                <div class="col-lg">
                    <div class="card">
                        <div class="card-header">
                            <h4>已发送</h4>
                        </div>

                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-body">
                                    <form class="form-inline" th:action="@{/sms/info/list}" method="post">
                                        <div class="form-group col-lg-4 mb-3">
                                            <label for="startDate" class=" col-sm-3 mr-3">开始时间</label>
                                            <input type="text" id="startDate" name="startDate"
                                                   style="background-color: white !important;"
                                                   class="Wdate mr-3  col-sm-7 form-control "
                                                   onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')}'})"
                                                   th:value="${startDate}" readonly unselectable="on"/>
                                        </div>
                                        <div class="form-group col-lg-4 mb-3">
                                            <label for="endDate" class="col-sm-3 mr-3">结束时间</label>
                                            <input type="text" id="endDate" name="endDate"
                                                   style="background-color: white !important;"
                                                   class=" Wdate mr-3 col-sm-7 form-control "
                                                   onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}'})"
                                                   th:value="${endDate}" readonly unselectable="on"/>
                                        </div>
                                        <div class="form-group col-lg-4 mb-3 pull-right">
                                            <input type="hidden" th:value="${currentPage}"
                                                   id="currentPage" name="currentPage">
                                            <input type="submit" value="查询" class="col-sm-3 mr-3 btn btn-primary">
                                            <input id="clearBtn" type="button" value="重置"
                                                   class="col-sm-3 mr-3 btn btn-success">
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <!--tables start -->
                        <div class="col-lg-12 grid-margin stretch-card">
                            <div class="card">
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered">
                                            <thead>
                                            <td class="tc text-center" style="width: 4%;">序号</td>
                                            <td class="tc text-center " style="width: 8%;">发送状态</td>
                                            <td class="tc text-center " style="width: 10%;">短信类型</td>
                                            <td class="tc text-center " style="width: 10%;">接收人</td>
                                            <td class="tc  text-center " style="width: 10%;">短信主题</td>
                                            <td class="tc  text-center " style="width: 18%;">短信正文</td>
                                            <td class="tc  text-center " style="width: 13%;">发送时间</td>
                                            <td class="tc  text-center" style="width: 34%;">操作</td>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr th:each="data,loopStatus:${data}">
                                                <td class="tc" th:text="${loopStatus.count}"></td>
                                                <td class="tc"
                                                    th:text="${data.msgStatus==0?'发送中':data.msgStatus==1?'已发送':data.msgStatus==2?'发送失败':data.msgStatus==3?'部分发送成功':''}"></td>
                                                <td class="tc"
                                                    th:text="${data.msgType==1?'普通短信':data.msgType==2?'定时短信':data.msgType==3?'群发短信':''}"></td>
                                                <td class="tc"
                                                    th:title="${(data.receiveBookUserName!=null && data.receiveBookUserName!='' && data.receiveOrtherUserPhone!=null && data.receiveOrtherUserPhone!='') ? (data.receiveBookUserName+','+data.receiveOrtherUserPhone):((data.receiveBookUserName==null || data.receiveBookUserName=='') ?((data.receiveOrtherUserPhone==null || data.receiveOrtherUserPhone=='')?'':data.receiveOrtherUserPhone):data.receiveBookUserName)}"
                                                    th:text="${(data.receiveBookUserName!=null && data.receiveBookUserName!='' && data.receiveOrtherUserPhone!=null && data.receiveOrtherUserPhone!='') ? (data.receiveBookUserName+','+data.receiveOrtherUserPhone):((data.receiveBookUserName==null || data.receiveBookUserName=='')?((data.receiveOrtherUserPhone==null || data.receiveOrtherUserPhone=='')?'':data.receiveOrtherUserPhone):data.receiveBookUserName)}"></td>
                                                <td class="tc" th:text="${data.msgSubject==null?'':data.msgSubject}"
                                                    th:title="${data.msgSubject==null?'':data.msgSubject}"></td>
                                                <td class="tc" th:text="${data.msgContent==null?'':data.msgContent}"
                                                    th:title="${data.msgContent==null?'':data.msgContent}"></td>
                                                <td class="tc"
                                                    th:text="${#dates.format(data.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                                <td class="tc">
                                                    <a href="javascript:void(0)"
                                                       th:onclick="getOne([[${data.id}]])"
                                                       class="mr-3">详情</a>
                                                    <a href="javascript:void(0)"
                                                       th:onclick="editSms([[${data.id}]],[[${data.msgType}]],[[${data.smsGroupId}]])"
                                                       class="mr-3">编辑</a>
                                                    <a href="javascript:void(0)"
                                                       th:onclick="forwardSms([[${data.id}]],[[${data.msgType}]],[[${data.smsGroupId}]])"
                                                       class="mr-3">转发</a>
                                                    <a href="javascript:void(0)" data-toggle="modal"
                                                       data-target="#deleteSmsInfo"
                                                       th:onclick="deleteSmsInfo([[${data.id}]],[[${data.msgSubject}]])"
                                                       class="mr-3">删除</a>
                                                    <a href="javascript:void(0)" data-toggle="modal"
                                                       data-target="#deleteThoRoughSmsInfo"
                                                       th:onclick="deleteThoRoughSmsInfo([[${data.id}]],[[${data.msgSubject}]])"
                                                       class="mr-3">彻底删除</a>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="col-lg-6 float-none float-sm-left">
                                        <small
                                                th:text="'共'+${data.totalElements}+'条记录，每页'+${data.size}+'条,共'+${data.totalPages}+'页'"></small>
                                    </div>
                                    <div th:replace="~{/pages/common/pagination.html :: page(${data.number}+1, ${data.totalPages}, ${url}, 'currentPage') }"></div>
                                </div>
                            </div>
                        </div>
                        <!--tables end -->
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!--页码-->
    <div th:replace="~{/pages/common/foot.html}"></div>
</div>

<!-- 删除Modal -->
<div class="modal fade" id="deleteSmsInfo" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
     aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleDeleteSmsInfoTitle1">删除</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body ">
                <input value="" class="deleteSmsInfo_id" type="hidden">
                <p class="deleteSmsInfo_message"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary delSmsInfoSure" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<!-- 彻底删除Modal -->
<div class="modal fade" id="deleteThoRoughSmsInfo" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
     aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleDeleteThoRoughSmsInfoTitle1">彻底删除</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body ">
                <input value="" class="deleteThoRoughSmsInfo_id" type="hidden">
                <p class="deleteThoRoughSmsInfo_message"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary delThoRoughSmsInfoSure" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
</body>
<!-- JavaScript files-->
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/vendor/popper.js/umd/popper.min.js}"></script>
<script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>
<script th:src="@{/js/grasp_mobile_progress_circle-1.0.0.min.js}"></script>
<script th:src="@{/vendor/jquery.cookie/jquery.cookie.js}"></script>
<!--<script th:src="@{/vendor/chart.js/Chart.min.js}"></script>-->
<script th:src="@{/vendor/jquery-validation/jquery.validate.min.js}"></script>
<script th:src="@{/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js}"></script>


<script language="javascript" type="text/javascript" th:src="@{/My97DatePicker/WdatePicker.js}"></script>
<!-- Main File-->
<script th:src="@{/js/front.js}"></script>
<script th:src="@{/js/toastr.min.js}"></script>
<script th:src="@{/js/base.js}"></script>
<script type="text/javascript">
    toastr.options = {
        closeButton: false, //是否显示关闭按钮（提示框右上角关闭按钮）；
        debug: false, //是否为调试；
        progressBar: false, //是否显示进度条（设置关闭的超时时间进度条）
        positionClass: "toast-top-center", //消息框在页面显示的位置
        onclick: null, //点击消息框自定义事件
        showDuration: "300", //显示动作时间
        hideDuration: "1000", //隐藏动作时间
        timeOut: "2000", //自动关闭超时时间
        extendedTimeOut: "1000",
        showEasing: "swing",
        hideEasing: "linear",
        showMethod: "fadeIn",
        hideMethod: "fadeOut"
    };
    $("#clearBtn").click(function () {
        window.location.href = $appName + "/sms/info/list";
    })

    function getOne(id) {
        window.location.href = $appName + "/sms/info/one?id=" + id + "&" + $('form').serialize();
    }

    function deleteSmsInfo(id, name) {
        $(".deleteSmsInfo_id").val(id);
        $(".deleteSmsInfo_message").text("是否确认删除'" + name + "'?");
    }

    function deleteThoRoughSmsInfo(id, name) {
        $(".deleteThoRoughSmsInfo_id").val(id);
        $(".deleteThoRoughSmsInfo_message").text("彻底删除后将无法恢复，您确定要删除'" + name + "'吗?");
    }

    function editSms(id, msgType, groupId) {
        debugger;
        if (msgType == 1 || groupId == null || groupId == "") {//普通短信
            sessionStorage.setItem("menuCheckedId", "8a808eb673472c440173473090c00019");
            sessionStorage.setItem("hasSub", 0);
            window.location.href = $appName + "/home/index?id=" + id + "&flag=sendSms&" + $("form").serialize();
        } else if (msgType == 3 || (msgType == 2 && groupId != null && groupId != "")) {//群发短信 or 定时短信
            //记录已发送页面
            sessionStorage.setItem("flag", "groupSend");
            sessionStorage.setItem("sendListParam", $("form").serialize());
            sessionStorage.setItem("menuCheckedId", "4028468173747b4001737563ee1d00b3");
            sessionStorage.setItem("hasSub", 0);
            window.location.href = $appName + "/sms/sendGroup/sendIndex?id=" + id + "&groupId=" + groupId + "&flag=groupSend&" + $("form").serialize();
        }

    }

    function forwardSms(id, msgType, groupId) {
        if (msgType == 1 || groupId == null || groupId == "") {//普通短信
            sessionStorage.setItem("menuCheckedId", "8a808eb673472c440173473090c00019");
            sessionStorage.setItem("hasSub", 0);
            window.location.href = $appName + "/sms/info/forward?id=" + id + "&flag=sendSms&" + $('form').serialize();
        } else if (msgType == 3 || (msgType == 2 && groupId != null && groupId != "")) {//群发短信 or 定时短信
            //记录已发送页面
            sessionStorage.setItem("flag", "groupSend");
            sessionStorage.setItem("sendListParam", $("form").serialize());
            sessionStorage.setItem("menuCheckedId", "4028468173747b4001737563ee1d00b3");
            sessionStorage.setItem("hasSub", 0);
            window.location.href = $appName + "/sms/info/forward?id=" + id + "&flag=groupSend&" + $("form").serialize();
        }


    }

    //确认删除方法
    $(".delSmsInfoSure").click(function () {
        let id = $(".deleteSmsInfo_id").val();
        $.requestAjax({
                url: $appName + "/sms/info/delete",
                type: "post",
                data: {"id": id, "status": 3},
                success: function (result) {
                    if (result.success) {
                        toastr.success(result.msg);
                        setTimeout(function () {
                            window.location.reload();//刷新当前页面.
                        }, 1500)
                    } else {
                        toastr.error(result.msg);
                    }

                }
            }
        )
    })
    //确认彻底删除方法
    $(".delThoRoughSmsInfoSure").click(function () {
        let id = $(".deleteThoRoughSmsInfo_id").val();
        $.requestAjax({
                url: $appName + "/sms/info/delete",
                type: "post",
                data: {"id": id},
                success: function (result) {
                    if (result.success) {
                        toastr.success(result.msg);
                        setTimeout(function () {
                            window.location.reload();//刷新当前页面.
                        }, 1500)
                    } else {
                        toastr.error(result.msg);
                    }

                }
            }
        )
    })


</script>
</html>